
function upload_img(){
    Modal.confirm({
        msg:"是否继续?"
    }).on(function(e){
        if(e==true){

            var formData =new FormData($("#uploadForm")[0]);

            $.ajax({
                type:"POST",
                url:"/save_img/",
                data:formData,
                dataType:'json',
                async:false,
                cache:false,
                contentType:false,
                processData:false,
                success:function(data){
                    if(data.code==1){
                        alert("OK,上传图片成功")
                    }
                }
            });
        }
    });

}

function editgoods_img(){
    Modal.confirm({
        msg:"是否继续？"
    }).on(function (e) {
        if(e==true){
            var id =$("#hi_id").val();
            var flag=$("#hi_type").val();
            $('#uploadimg').ajaxSubmit({
                type:"POST",
                url:"/edit_goods_img/",
                data:{id:id,type:flag},
                dataType:"json",
                success:function (data) {
                    if(data.code=='1'){
                        alert("操作成功!");
                        $("#img_xb1").attr("src",data.m_img);
                        $("#img_xb2").attr("src",data.m_img);
                    }
                    else{
                        alert("操作失败")
                    }
                }
            });
        }
    });
}


function add_materiels(){
    Modal.confirm({
        msg:"是否继续?"
    }).on(function (e) {
        if(e==true){
            var m_code =$("#txt_code").val();
            var m_name =$('#txt_name').val();
            var m_type = $('#txt_type').val();
            var m_spec = $('#txt_spec').val();
            var m_unit = $('#txt_unit').val();
            var m_mcu = $('#txt_mcu').val();
            var m_use =$("#txt_use").val();
            var m_remark = $('#txt_remark').val();
            $('#uploaddata').ajaxSubmit({
                type:"POST",
                url:"/add_mate_data/",
                data:{code:m_code,name:m_name,type:m_type,spec:m_spec,unit:m_unit,mcu:m_mcu,use:m_use,remark:m_remark},
                dataType:"json",
                success:function(data){
                    if(data.code ==1)
                    {
                        alert("json:操作成功!")
                    }
                    else
                        alert("操作失败!")
                }
            });
        }
    });

} // add_materiels end;


function edit_materiels () {
        Modal.confirm({
            msg:"是否继续？"
        }).on(function(e){
            if(e==true)
            {
                var m_code =$("#txt_code").val();
                var m_name =$('#txt_name').val();
                var m_type = $('#txt_type').val();
                var m_spec = $('#txt_spec').val();
                var m_unit = $('#txt_unit').val();
                var m_mcu = $('#txt_mcu').val();
                var m_use =$("#txt_use").val();
                var m_remark = $('#txt_remark').val();
                var m_id = $("#hi_id").val();
                $.ajax({
                    type:"POST",
                    url:"/edit_mate_data/",
                    data:{id:m_id,code:m_code,name:m_name,type:m_type,spec:m_spec,unit:m_unit,mcu:m_mcu,use:m_use,remark:m_remark},
                    dataType:"json",
                    success:function(data){
                        if(data.code ==1){
                            alert("操作成功")
                        }
                    }
                });
            }
        });
}  // edit_materiels end;



function del_materiels(){
        Modal.confirm({
            msg:"是否继续？"
        }).on(function (e) {
            if(e==true){
                var m_id = $("#hi_id").val();
                $('#uploaddata').ajaxSubmit({
                    type:"POST",
                    url:"/del_mate_data/",
                    data:{id:m_id},
                    dataType:"json",
                    success:function(data){
                        if(data.code ==1){
                            alert(data.msg);
                        }
                    }
                });
            }
        });
    } // del_materiels end;